<!-- 我的日记 主诉组件  -->

<template>
	<view class="record">
		<view class="mb20" v-for="(item,index) in newList" :key="index">
			<view class="recordItem">
				<view class="">时间</view>
				
				<picker mode="time"  @change="changeTimePicker(index,$event)">
					<view>{{item.time?item.time:'请选时间'}} <text class="icon arrow"></text> </view>
				</picker>
				
			</view> 
			<view class="" v-for="(it,ind) in item.symptom" :key="ind">
				<view class="recordItem"   @click="path(`/plugins/symptoms/index?data=${JSON.stringify(it)}&pi=${index}&ci=${ind}&type=diary`)">
					<view class="recordChild">
						<view @click.stop="delectTap(index,ind)" class="close">
							<image src="../../static/images/del.png" mode=""></image>
						</view>
						<view class="recordName">{{it.name}}</view>
					</view>
					<view class="recordChild">
						<view class="">{{it.where}}{{it.name}}</view>
						<view class="icon arrow"></view>
					</view>
				</view>
				
				<view class="flex flex-jcsa flex-aic p20 ">
					<view :class="['btn',it.change == -1?'act':'']" @click="selectMoment(index,ind,-1)">减轻</view>
					<view :class="['btn',it.change == 0?'act':'']" @click="selectMoment(index,ind,0)">不变</view>
					<view :class="['btn',it.change == 1?'act':'']" @click="selectMoment(index,ind,1)">加重</view>
				</view>
			</view>
			
			<view class="recordItem">
				<view class="recordChild">
					<view class="icon f36 mr20"></view>
					<view class="recordName">症状</view>
				</view>
				<view class="recordChild" @click="path(`/plugins/symptoms/index?pi=${index}&ci=-1&type=diary`)">
					<view class="">添加</view>
					<view class="icon arrow"></view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	
	export default {
		name:"",
		data() {
			return {
				showPeriod:false,
				periodIndex:0,
				startTime:'',
				endTime:''
			}
		},
		props:{
			lists:{
				type:Array,
				default:()=>{
					return []
				}
			},
			types:{
				type:String,
				default:''
			},
			paths:{
				type:String,
				default:''
			},
			istime:{
				type:String,
				default:""
			}
		},
		computed:{
			newList(){
				console.log(this.lists);
				this.lists.forEach(it => {
					it.symptom.forEach(item=>{
						switch (item.id) {
							case 'SM003':
								item = Object.assign(item, {
									name: "僵直"
								})
								break;
							case 'SM017':
								item = Object.assign(item, {
									name: "迟缓"
								})
								break;
							case 'SM018':
								item = Object.assign(item, {
									name: "震颤"
								})
								break;
							case 'SM013':
								item = Object.assign(item, {
									name: "步态异常"
								})
								break;
							case 'SM014':
								item = Object.assign(item, {
									name: "启动困难"
								})
								break;
							case 'SM015':
								item = Object.assign(item, {
									name: "平衡障碍"
								})
								break;
							case 'SM022':
								item = Object.assign(item, {
									name: "异动"
								})
								break;
							case 'SM023':
								item = Object.assign(item, {
									name: "无力"
								})
								break;
							case 'SM024':
								item = Object.assign(item, {
									name: "麻木"
								})
							default:
								break;
						}
					})
				})
				return this.lists;
			},
		},
		onLoad() {
	
		},
		onShow() {
			
		},
		methods: {
			/** 单时间返回
			 * @param {Object} e 弹窗返回数据
			 * @param {Object} i 第几个
			 */
			selectMoment(index,ind,num){
				this.$emit('selectMoment',{index,ind,num})
			},
			changeTimePicker(i,e){
				this.$emit('change',{i,time:e.detail.value})
			},
			
			// 删除数据
			delectTap(index,ind){
				this.$emit('delectTap',{index,ind})
			},
			//  弹起时间段弹窗
			selectTime(index){
				
				this.showPeriod = true;
				this.periodIndex = index;
			},
			// 取消时间段弹窗
			cancel(){
				this.showPeriod = false;
			},
			/** 时间段弹窗点击确定
			 * @param {Object} e 子组件lkTimeperiod返回时间段
			 */
			submit(e){
				this.lists[this.periodIndex].time =e;
				this.showPeriod = false;
			},
			// 页面跳转
			path(url){
				this.$routeJump.navigateTo(url)
			}
		}
	}
	
</script>

<style lang="scss" scoped>
	.recordItem{
		padding: 20rpx 0;
		font-size: 36rpx;
		@include flex(space-between,center);
		.recordChild{
			@include flex(flex-start,center)
			.recordName{
				width:140rpx
			}
			
		}
		
	}
	
	.act{
		background-color:#6aa1a8 !important;
	}
	.close{
		width:46rpx;
		height: 46rpx;
		margin-right: 14rpx;
	}
</style>
